\usepackage{graphicx}
\usepackage{indentfirst}
\usepackage[usenames,dvipsnames]{color}
\usepackage{fancyvrb} % for verbatim
\usepackage{fancyhdr}
\usepackage{listings}
\usepackage[sf]{titlesec}
\usepackage{titletoc}
\usepackage[boldfont,slantfont,CJKnumber]{xeCJK}
\usepackage{xcolor} % 使用颜色宏包
\usepackage{color}
\usepackage{amsmath, amsfonts, epsfig, xspace}
\usepackage{algorithm,algorithmic}
\usepackage[normal,tight,center]{subfigure}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{multicol}
\usepackage{colortbl}

\definecolor{steelblue}{rgb}{.275,.51,.71}
\definecolor{lpink}{rgb}{.991,.711,.754}
\definecolor{mygray}{gray}{0.92}
\definecolor{darkblue}{rgb}{0,0,.5}
\definecolor{darkgreen}{rgb}{0,.39,0}
\definecolor{hgray}{gray}{.5}
\definecolor{lgray}{gray}{.8}

\usepackage[colorlinks=true,urlcolor=blue,linkcolor=blue]{hyperref} % for links and anchors

\setCJKmainfont[BoldFont=Adobe Heiti Std]{Adobe Song Std} % 设置默认的中文字体
\setCJKfamilyfont{kai}{Adobe Kaiti Std}
\setCJKfamilyfont{hei}{Adobe Heiti Std}
\setCJKfamilyfont{li}{LiSu}

\newcommand{\kai}{\CJKfamily{kai}}
\newcommand{\hei}{\CJKfamily{hei}}
\newcommand{\li}{\CJKfamily{li}}

\newcommand{\sectionname}{第\CJKnumber{\thesection}章}
\newcommand{\myheader}[1]{\textcolor{darkblue}{#1}}

\def\projectName{Enhance2web20}
\renewcommand\contentsname{目录}

\special{ pdf: bgcolor [ 1.00 0.98 0.95 ] }

\linespread{1.382}

\pagestyle{fancy}

\makeatletter
  \fancyhf{}
  \lhead{\textcolor{hgray}\@title}
  \rhead{\textcolor{hgray}\leftmark} 
\makeatother

\makeatletter
\renewcommand{\maketitle}{
\begin{titlepage}%
\let\footnotesize\small
    \let\footnoterule\relax
    \parindent \z@
    \reset@font
    \vskip 10\p@
    \hbox{\mbox{%
        \hspace{4pt}%
        \fbox{\includegraphics[width=6em]{../logo.png}}%
        \hspace{4pt}
        }%
     \vrule depth 0.8\textheight%
     \mbox{\hspace{2em}}
     \vtop{% %%%%%%%%%%%%%%%%%%
        \vskip 40\p@
        \begin{flushleft}
          \Large \projectName \par
        \end{flushleft}
        \vskip 80\p@
        \begin{flushleft}
        \textcolor{steelblue}{ \fontsize{48}{20pt} \bfseries \li \@title }\par
        \end{flushleft}
        
      }
     }
     \rightline{By \@author}

  \end{titlepage}%
}

\makeatother


\titleformat{\section}[hang]{\LARGE\sf\kai}
            {\myheader\sectionname}
            {1em}
            {\myheader}[\color{steelblue}{\titlerule}]

\titleformat{\subsection}[hang]{\Large\sf\kai}
            {\myheader\thesubsection}
            {1em}
            {\myheader}
\titleformat{\subsubsection}[hang]{\large\sf\kai}
            {\myheader\thesubsubsection}
            {1em}
            {\myheader}


\titlecontents{section}
              [2em]{\large\sf\kai\addvspace{-0.1em}}
              {\thecontentslabel\quad}
%%            {\hspace*{-2.3em}}
              {}
              {\titlerule*[0.8pc]{.}\contentspage}
\titlecontents{subsection}
              [4em]{\small\addvspace{-0.2em}}
              {\thecontentslabel\quad}
%%            {\hspace*{-2.3em}}
              {}
              {\titlerule*[0.8pc]{.}\contentspage}
\titlecontents{subsubsection}
              [6em]{\small\addvspace{-0.2em}}
              {\thecontentslabel\quad}
%%            {\hspace*{-2.3em}}
              {}
              {\titlerule*[0.8pc]{.}\contentspage}



\lstset{
keywordstyle=\color{blue!70}, commentstyle=\color{red!50!green!50!blue!50},
frame=shadowbox,
rulesepcolor=\color{red!20!green!20!blue!20}
}
\lstset{breaklines}%这条命令可以让LaTeX自动将长的代码行换行排版
\lstset{extendedchars=false}

% \lstset{ xleftmargin=2em,xrightmargin=2em, aboveskip=1em}
